//2.利用指针变量计算下标为奇数的数组的和
#include<stdio.h>
int exchange(int *p, int n)
{
	int sum = 0;
	p++;
	int *q = p + n - 1;
	for(;p <= q; p += 2)
	{
		sum += *p;
	}
	return sum;
}
int main()
{
	int a[] = {1,2,3,4,5,6,7,8};
	int n = sizeof a / sizeof a[0];
	int sum = exchange(a,n);
	printf("下标为奇数的数组的和：%d\n",sum);
	return 0;
}
